package may.qf.controller;

import may.qf.entity.Emp;
import may.qf.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private EmpService empService;

    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public String login(Integer empNo, String ename, HttpSession session) {
        Emp emp = empService.login(empNo, ename);
        session.setAttribute("userLogin", emp);
        return "index";
    }

    @RequestMapping("/logOut")
    public String logOut(HttpSession session){
        session.removeAttribute("userLogin");
        return "index";
    }
}
